package com.link2room.ironhide.controller.api;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.common.jpa.result.QueryResult;
import com.link2room.ironhide.dto.param.api.GroupAreaApiParamDto;
import com.link2room.ironhide.dto.result.base.PositionBaseDto;
import com.link2room.ironhide.dto.result.api.L2RGroupAreaApiDto;
import com.link2room.ironhide.dto.result.api.L2RGroupCityDetailApiDto;
import com.link2room.ironhide.facade.IGroupAreaApiFacadeService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by sss on 2016/10/11.
 */
@Api(tags = "集团区域")
@RestController
@RequestMapping("/api/GroupAreas")
public class  GroupAreaApiController {
    @Resource
    private IGroupAreaApiFacadeService groupAreaApiFacadeService;

    @RequestMapping(value = "/Citys",method = RequestMethod.GET)
    public BaseResultDto citys() throws Exception {
        GroupAreaApiParamDto groupAreaApiParamDto=new GroupAreaApiParamDto();
        L2RGroupAreaApiDto l2rGroupCityList = groupAreaApiFacadeService.listL2RGroupCity(groupAreaApiParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(l2rGroupCityList);
        return l2rRs;
    }

    @RequestMapping(value = "/HotCitys",method = RequestMethod.GET)
    public BaseResultDto hotCitys() throws Exception {
        GroupAreaApiParamDto groupAreaApiParamDto=new GroupAreaApiParamDto();
        QueryResult<L2RGroupCityDetailApiDto> l2rGroupHotCityResult = groupAreaApiFacadeService.listL2RGroupHotCity(groupAreaApiParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setQueryResult(l2rGroupHotCityResult);
        return l2rRs;
    }

    @RequestMapping(value = "/Positions",method = RequestMethod.GET)
    public BaseResultDto districts(
            @RequestParam(value = "cityCode" ,required = true) Long cityCode
    ) throws Exception {
        GroupAreaApiParamDto groupAreaApiParamDto=new GroupAreaApiParamDto();
        groupAreaApiParamDto.setCityCode(cityCode);
        List<PositionBaseDto> l2RPositionBaseDtos=groupAreaApiFacadeService.listGroupPositionBase(groupAreaApiParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(l2RPositionBaseDtos);
        return l2rRs;
    }
}
